<?php

if(!defined('OT_ROOT')) {
	exit('Access Denied');
}


class IdcProType{

	// 数据库对象
	public $mTypeArr;
	public $mTypeFatArr;
	public $mTopicArr;

	public $noStr;


	// 构造函数
	public function __construct($showArr = array('type'=>true)){
		global $DB;

		$this->noStr	= '[已不存在]';

		$this->mTypeArr = array();
		$this->mTypeFatArr = array();
		if (! empty($showArr['type'])){
			$typecnexe=$DB->query('select IPT_ID,IPT_theme,IPT_fatID from '. OT_dbPref .'idcProType order by IPT_ID DESC');
			while ($row = $typecnexe->fetch()){
				$this->mTypeArr[$row['IPT_ID']] = $row['IPT_theme'];
				$this->mTypeFatArr[$row['IPT_fatID']][$row['IPT_ID']] = array(
					'id'	=> $row['IPT_ID'],
					'theme'	=> $row['IPT_theme']
					);
			}
			unset($typecnexe);
		}
	}


	// 类别
	function TypeStrCN($str, $sign=''){
		global $systemArr;

		$newStr = '';
		$selStr = 0;
		$selStr2= 0;
		$newArr = explode(',', $str);
		$newCount = count($newArr);
		for ($i=0; $i<$newCount; $i++){
			$newArr[$i] = intval($newArr[$i]);
			if ($newArr[$i] > 0){
				$selStr ++;
				if ($selStr > 1){
					$selStr2 ++;
					if (strlen($sign) == 0){ $sign = '<br />'. str_repeat('　', $selStr2) .'┣&ensp;'; }
					$newStr .= $sign . $this->TypeCN($newArr[$i]) .'';
				}else{
					$newStr .= $this->TypeCN($newArr[$i]) .'';
				}
			}
		}
		return $newStr;
	}


	function TypeCN($id){
		if (! isset($this->mTypeArr[$id]) ){
			return $this->noStr;
		}else{
			return $this->mTypeArr[$id];
		}
	}

}
?>